#ifndef __LVD_H
#define __LVD_H

#include "system_remap.h"

#define LVD_LEVEL_MASK		0x001F
#define LVD_EN_MASK				0x0020
#define LVD_LVDF_MASK			0x0040

/*LVD LEVEL*/
#define LVD_LEVEL_1V7			0x00
#define LVD_LEVEL_1V8			0x01
#define LVD_LEVEL_1V9			0x02
#define LVD_LEVEL_2V0			0x03
#define LVD_LEVEL_2V1			0x04
#define LVD_LEVEL_2V2			0x05
#define LVD_LEVEL_2V3			0x06
#define LVD_LEVEL_2V4			0x07
#define LVD_LEVEL_2V5			0x08
#define LVD_LEVEL_2V6			0x09
#define LVD_LEVEL_2V7			0x0A
#define LVD_LEVEL_2V8			0x0B
#define LVD_LEVEL_2V9			0x0C
#define LVD_LEVEL_3V0			0x0D
#define LVD_LEVEL_3V1			0x0E
#define LVD_LEVEL_3V2			0x0F
#define LVD_LEVEL_3V3			0x10
#define LVD_LEVEL_3V4			0x11
#define LVD_LEVEL_3V5			0x12
#define LVD_LEVEL_3V6			0x13
#define LVD_LEVEL_3V7			0x14
#define LVD_LEVEL_3V8			0x15
#define LVD_LEVEL_3V9			0x16
#define LVD_LEVEL_4V0			0x17
#define LVD_LEVEL_4V1			0x18
#define LVD_LEVEL_4V2			0x19
#define LVD_LEVEL_4V3			0x1A
#define LVD_LEVEL_4V4			0x1B
#define LVD_LEVEL_4V5			0x1C
#define LVD_LEVEL_4V6			0x1D
#define LVD_LEVEL_4V7			0x1E
#define LVD_LEVEL_4V8			0x1F
typedef struct
{
	__IO uint16_t CR;	
}LVD_TypeDef;
typedef struct
{
	uint8_t LVD_LEVEL;
	uint8_t LVD_CMD;	
}LVD_InitTypeDef;
///////////////////////////////////////////
#define LDO_LEVEL_MASK			0x1800
#define LDO_DIVER_MASK			0x2000
enum {
	LDO_LEVEL_2V6 = 0,
	LDO_LEVEL_2V8,
	LDO_LEVEL_3V0,
	LDO_LEVEL_3V3,
};
enum {
	LDO_DIVER_LOW = 0,
	LDO_DIVER_HIGH,
};
typedef struct
{
	__IO uint16_t CR;	
}LDO_TypeDef;
#define LDO_OFF  do{*(uint32_t *)(LDO_BASE) |= 0x0400;}while(0); //bit 10
#define LDO_ON   do{*(uint32_t *)(LDO_BASE) &= 0xFBFF;}while(0); //bit 10

#define LDO_NORMOR_POWER do{*(uint32_t *)(LDO_BASE) |= 0x2000;}while(0); //bit 13
#define LDO_LOW_POWER    do{*(uint32_t *)(LDO_BASE) &= 0xDFFF;}while(0); //bit 13
//////////////////////////////////////////////////////////////////////////





void LVD_Init(LVD_InitTypeDef* LVD_InitStruct);

void LVD_LevelSet(uint8_t LevelVal);

uint8_t LVD_LevelGet(void);

uint8_t LVD_GetFlagStatus(void);

void LVD_CleanFlag(void);

void LVD_Cmd(FunctionalState NewState);
void sys_reset(void);
#endif //
